package net.zoneland.knowledge.config;

import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.ErrorPageRegistrar;
import org.springframework.boot.web.server.ErrorPageRegistry;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;

/**
 * .
 *
 * @author: bcc
 * 2021/11/16
 */
@Configuration
public class ErrorConfiguration implements ErrorPageRegistrar {

    @Override
    public void registerErrorPages(ErrorPageRegistry registry) {
        ErrorPage[] errorPages = new ErrorPage[5];
        errorPages[0] = new ErrorPage(HttpStatus.UNAUTHORIZED, "/401.jsp");
        errorPages[1] = new ErrorPage(HttpStatus.PAYMENT_REQUIRED, "/402.jsp");
        errorPages[2] = new ErrorPage(HttpStatus.FORBIDDEN, "/403.jsp");
        errorPages[3] = new ErrorPage(HttpStatus.NOT_FOUND, "/404.jsp");
        errorPages[4] = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/500.jsp");

        registry.addErrorPages(errorPages);
    }
}
